package com.legal.aid.app.controller;


import com.legal.aid.app.domain.vo.LawRegulationVo;
import com.legal.aid.app.service.IAppLawRegulationService;
import com.legal.aid.common.core.controller.BaseController;
import com.legal.aid.common.core.domain.AjaxResult;
import com.legal.aid.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/app/lawRegulation")
public class AppLawRegulationController extends BaseController {

    @Autowired
    private IAppLawRegulationService appLawRegulationService;


    /**
     * 查询法律法规列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LawRegulationVo lawRegulation)
    {
        startPage();
        List<LawRegulationVo> list = appLawRegulationService.selectLawRegulationVoList(lawRegulation);
        System.out.println("查到的list.size()=" + list.size());
        return getDataTable(list);
    }


    /**
     * 获取法律法规详细信息
     */
    @GetMapping(value = "/{lawId}")
    public AjaxResult getInfo(@PathVariable("lawId") Long lawId)
    {
        return success(appLawRegulationService.selectLawRegulationVoByLawId(lawId));
    }

    /**
     * 获取当前登录用户法律法规的关注列表
     */
    @GetMapping("/attention")
    public AjaxResult selectAttentionLawRegulationList()
    {
        List<LawRegulationVo> list = appLawRegulationService.selectAttentionLawRegulationVoList();
        return AjaxResult.success(list);
    }
}
